package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TourismStatistics;
import com.ruoyi.system.service.ITourismStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据统计Controller
 *
 * @author gqd
 * @date 2021-02-03
 */
@RestController
@RequestMapping("/system/statistics")
public class TourismStatisticsController extends BaseController
{
    @Autowired
    private ITourismStatisticsService tourismStatisticsService;

    /**
     * 查询数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourismStatistics tourismStatistics)
    {
        startPage();
        List<TourismStatistics> list = tourismStatisticsService.selectTourismStatisticsList(tourismStatistics);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 导出数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:export')")
    @Log(title = "数据统计", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourismStatistics tourismStatistics)
    {
        List<TourismStatistics> list = tourismStatisticsService.selectTourismStatisticsList(tourismStatistics);
        ExcelUtil<TourismStatistics> util = new ExcelUtil<TourismStatistics>(TourismStatistics.class);
        return util.exportExcel(list, "statistics");
    }

    /**
     * 获取数据统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tourismStatisticsService.selectTourismStatisticsById(id));
    }

    /**
     * 新增数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:add')")
    @Log(title = "数据统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourismStatistics tourismStatistics)
    {
        return toAjax(tourismStatisticsService.insertTourismStatistics(tourismStatistics));
    }

    /**
     * 修改数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:edit')")
    @Log(title = "数据统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourismStatistics tourismStatistics)
    {
        return toAjax(tourismStatisticsService.updateTourismStatistics(tourismStatistics));
    }

    /**
     * 删除数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:remove')")
    @Log(title = "数据统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tourismStatisticsService.deleteTourismStatisticsByIds(ids));
    }
}
